package com.ruubypay.miss.miniotest.demos.web;

import com.ruubypay.miss.miniotest.pojo.Machine;
import com.ruubypay.miss.miniotest.repository.MachineRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Optional;

/**
 * @author fj
 * @date 2025/2/24 18:27
 */
@RequestMapping("/machine")
@RestController
public class MachineController {

    @Resource
    private MachineRepository machineRepository;
    @GetMapping("/{id}")
    public ResponseEntity<Machine> getMachine(@PathVariable("id") Long id){
        Optional<Machine> machine = machineRepository.findById(id);
        return ResponseEntity.ok(machine.orElse(null));
    }
}
